/* ===== 全体 ===== */

html,
body {
    overflow-x: hidden;
}

html {
    scroll-padding-top: 64px;
    /* ヘッダー高さ */
}

ul {
    padding-left: 10px;
}

body {
    margin: 0;
    font-family: "Rounded Mplus 1c", "Hiragino Maru Gothic ProN", sans-serif;
    background: linear-gradient(#fff7fb, #e6f7ff);
    color: #333;
    min-height: 100dvh;
    height: 100dvh;
    overflow-y: scroll;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;

    background-image: url("../img/top.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: bottom center;
    background-attachment: fixed;
    opacity: 0.35;
    -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.7) 40%, rgba(0, 0, 0, 0.2) 70%, rgba(0, 0, 0, 0) 100%);
    mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.7) 40%, rgba(0, 0, 0, 0.2) 70%, rgba(0, 0, 0, 0) 100%);
}

/* ===== ヘッダー ===== */
#header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 64px;
    background: #ff8acb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#header-wrapper {
    max-width: 960px;
    margin: auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
}

#header-wrapper.button-hidden {
    grid-template-columns: 1fr;
}

#header-wrapper.button-hidden button {
    display: none;
}

.header-title {
    display: flex;
    align-items: center;
    max-width: 100%;
    font-size: clamp(0.5em, calc(100vw / 16), 2em);
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    justify-content: center;
}

@media (max-width: 600px) {
    #header-wrapper {
        grid-template-columns: 1fr 1fr;
    }

    body:not(.menu) .header-title {
        display: none;
    }
}

/* ===== メイン ===== */
main {
    padding-top: 80px;
    max-width: 960px;
    margin: auto;
}

@media (max-width: 600px) {
    main {
        padding-top: 72px;
        padding-left: 12px;
        padding-right: 12px;
    }
}


/* ===== カード ===== */
.linear {
    background: linear-gradient(transparent 60%, #8ae7ff 60%);
}

.card {
    background: #fff;
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 6px 0 #ffd6e8;
    animation: pop 0.4s ease-out;
}

@media (max-width: 600px) {
    .card {
        border-radius: 14px;
        padding: 12px;
    }
}


@keyframes pop {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.card h2 {
    margin-top: 0;
    font-size: 1.4em;
}

/* #view-question {
     display: grid;
    grid-template-columns: 1fr 1fr; 
} */

.question-wrapper {
    margin-bottom: 15px;
    gap: 20px;
    background: white;
    border-radius: 16px;
    padding: 0 20px 20px 30px;
    margin-bottom: 30px;
    line-height: 1.8;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
    display: grid;

    &:has(.question.img) {
        grid-template-columns: 5fr 4fr;
    }
}

.question.story {
    margin: 20px;
}

@media (max-width: 768px) {

    .question-wrapper:has(.question.img),
    .question-wrapper {
        grid-template-columns: minmax(0, 1fr);
    }

    .question.img {
        margin: 10px 0;
    }
}

.question.img {
    align-content: center;
    text-align: center;
    margin: 20px;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #ffe4f1, #ffe4f1 10px, #fff 10px, #fff 20px);
}

.question.img img {
    display: block;
    width: 100%;
    object-fit: scale-down;
    aspect-ratio: 1;
}

h3 {
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 2px 6px;
    font-size: 1.17em;
}

@media (max-width: 600px) {
    h3 {
        font-size: 1.05em;
    }
}

.input-unit-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.question input,
.question select {
    font-size: 1.1em;
    padding: 6px 10px;
    width: 100px;
    border-radius: 8px;
    border: 2px solid #ccc;
}

.question input[autocapitalize="on"] {
    text-transform: uppercase;
}

@media (max-width: 600px) {

    .question input,
    .question select {
        width: 100%;
        font-size: 1em;
    }

    /* .input-unit-wrapper {
        flex-wrap: wrap;
    } */
}


/* ===== 選択肢 ===== */
.options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.question .options {
    width: 100%;
    grid-auto-columns: 1fr;
    /* grid-template-columns: 1fr; */
    grid-template-columns: repeat(3, 1fr);
}

.options label {
    /* display: block; */
    background: #f5f5f5;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    user-select: none;
    text-align: center;
}

.options input {
    display: none;
}

.options input:checked+span {
    background-color: #ff8acb;
    color: white;

    &.waddledee {
        background-color: #ffb833
    }

    &.kirby {
        background-color: #ff8acb
    }

    &.dedede {
        background-color: #8093ff
    }

    &.metaknight {
        background-color: #bf80ff
    }
}

.option-span {
    display: block;
    padding: 12px 0;
    border-radius: 20px;
}

@media (max-width: 600px) {
    .option-span {
        padding: 14px 0;
    }
}

.diff-img {
    height: 150px;
    margin-bottom: 6px;
    border-radius: 10px;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    background-position: center;
    background-repeat: no-repeat;
    background-size: auto 100%;

    &.waddledee {
        background-image: url("../img/chara-waddle_dee.png");
        ;
    }

    &.kirby {
        background-image: url("../img/chara-about-kirby.png");
        ;
    }

    &.dedede {
        background-image: url("../img/chara-dedede.png");
        ;
    }

    &.metaknight {
        background-image: url("../img/chara-meta_knight.png");
        ;
    }
}


/* ===== スタート ===== */
.start-area {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 10dvh;
}

.primary-btn {
    /* border-radius: 24px; */
    padding: 14px 40px;
    font-size: 1.5em;
    /* cursor: pointer; */
}

@media (max-width: 600px) {
    .primary-btn {
        width: 100%;
        padding: 14px 0;
        font-size: 16px;
    }
}


/* ===== ボタン ===== */

.submit-area {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 10dvh;
}

button {
    font-size: 1.1em;
    padding: 12px 22px;
    border-radius: 30px;
    border: none;
    background: #ff8acb;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    margin: 6px;
    font-weight: 700;
}

#header button {
    color: #ff8acb;
    background: white;
}

/* ===== ヒント ===== */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: gray;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 10px;
    background: gray;
    display: inline-block;
    width: max-content;
    overflow-wrap: break-word;

    /* Position the tooltip */
    position: absolute;
    z-index: 1;
    bottom: 100%;
    left: 50%;
    margin-left: -60px;
    opacity: 0.7;
    max-width: 30vw;
}

@media (max-width: 600px) {
    .tooltip .tooltiptext {
        max-width: 100vw;
        width: 90vw;
        right: 0;
    }
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}

.hint {
    background: #6dd3ff;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    text-align: center;
    line-height: 22px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    padding: 0 7px;
}

/* ===== 回答欄 ===== */
.answers {
    display: flex;
    gap: 15px;
}

.judge {
    position: relative;
    display: inline-block;
}

.judge .icon {
    padding: 8px 10px;
    font-size: 10em;
    color: tomato;
    fill: currentColor;
    position: absolute;
    z-index: 1;
    line-height: 100%;
    margin-left: -50px;
    opacity: 0.6;
    height: 100px;
}


/* ===== ローディング ===== */
.loading {
    text-align: center;
    font-size: 20px;
    margin-top: 40px;
    animation: hovering .3s ease infinite alternate;
    width: 100%;
    height: 80dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes hovering {
    0% {
        transform: translateY(0px);
    }

    100% {
        transform: translateY(-10px);
    }
}

/* ===== 演出 ===== */
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 999;
}

.star {
    position: absolute;
    opacity: 1;
    font-size: 20px;
    animation: fireworkFade 3s ease-out forwards;
}

@keyframes fireworkFade {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--dx), var(--dy)) scale(1);
        opacity: 0;
    }
}

.animated {
    -webkit-animation-duration: 1s;
    animation-duration: 1s;
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
    -webkit-animation-iteration-count: 1;
    animation-iteration-count: 1;
}

@-webkit-keyframes finish_img {
    from {
        -webkit-animation-timing-function: cubic-bezier(0.3, 0.6, 0.7, 0.4);
        -webkit-transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    to {
        -webkit-animation-timing-function: linear;
        -webkit-transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1;
    }

    4% {
        -webkit-animation-timing-function: cubic-bezier(0.3, 0.6, 0.7, 0.4);
        -webkit-transform: translate(0px, -100px) scale(1, 1.5) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    48% {
        -webkit-animation-timing-function: linear;
        -webkit-transform: translate(0px, -100px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    100% {
        -webkit-animation-timing-function: linear;
        -webkit-transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 0.0;
    }
}

@keyframes finish_img {
    from {
        animation-timing-function: cubic-bezier(0.3, 0.6, 0.7, 0.4);
        transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    to {
        animation-timing-function: linear;
        transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1;
    }

    4% {
        animation-timing-function: cubic-bezier(0.3, 0.6, 0.7, 0.4);
        transform: translate(0px, -100px) scale(1, 1.5) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    48% {
        animation-timing-function: linear;
        transform: translate(0px, -100px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }

    100% {
        animation-timing-function: linear;
        transform: translate(0px, 0px) scale(1, 1) rotate(0deg) skew(0deg, 0deg);
        opacity: 1.0;
    }
}

.finish_img {
    position: fixed;
    top: 0;
    left: 0;

    width: 100vw;
    height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 999;
    pointer-events: none;
    overflow: hidden;

    /* ❌ animationはここから削除 */
    /* ❌ transform-originも削除 */
}

.finish_img img {
    pointer-events: auto;

    max-width: 50vw;
    max-height: 50vh;

    width: auto;
    height: auto;

    object-fit: contain;

    /* ✅ アニメーションはimgに */
    animation: finish_img 0.8s both;

    /* Safari安定化 */
    will-change: transform;
    backface-visibility: hidden;
    transform-origin: center center;

    &:hover {
        animation: bounce 0.5s ease;
    }
}



@media (max-width: 600px) {
    .finish_img {
        max-width: 100%;
    }
}


/* アニメーションの基本設定 */
@keyframes bounce {
    0% {
        transform: translateY(0) scale(1);
    }

    30% {
        transform: translateY(-10px) scale(1.1);
    }

    50% {
        transform: translateY(0) scale(0.9);
    }

    70% {
        transform: translateY(-5px) scale(1.05);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

/* ===== 音声読み上げボタン ===== */
button.speak-play-btn{
    background: #fff;
    color: #ff8acb;
    box-shadow: 0 6px 14px #ff8acb;
}

.speak-play-btn .text-content span {
    /* デフォルトの色 */
    color: inherit;
    transition: color 0.1s;
}

.speak-play-btn .text-content span.highlight {
    color: #ff4500;
    /* オレンジレッド：目に飛び込んできやすい */
    font-weight: bold;
    background-color: #fffde7;
    /* ほんのり背景色をつけるとさらに見やすい */
}

/* ===== 音声入力 ===== */
.input-voice-wrapper {
    align-items: center;
    display: flex;
    width: 100%;
    gap: 0 10px;
}

/* ===== アコーディオンメニュー ===== */
.accordion {
    /* max-width: 500px;
    margin-bottom: 7px; */
    background-color: #f2f2f2;
    border-radius: 25px;
    padding: 16px;
    margin: 16px;
}

.accordion summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 1em 2em;
    color: #333333;
    font-weight: 600;
    cursor: pointer;
}

.accordion summary::-webkit-details-marker {
    display: none;
}

.accordion summary::after {
    transform: translateY(-25%) rotate(45deg);
    width: 7px;
    height: 7px;
    margin-left: 10px;
    border-bottom: 3px solid #c2c2c2;
    border-right: 3px solid #c2c2c2;
    content: '';
    transition: transform .3s;
}

.accordion[open] summary::after {
    transform: rotate(225deg);
}

/* ===== 共通 ===== */
.hidden {
    display: none;
}

.svg-defs {
    width: 0;
    height: 0;
    visibility: hidden;
    position: fixed;
    bottom: 0;
}

.emoji {
    height: 1em;
    width: 1em;
    margin: 0 .05em 0 .1em;
    vertical-align: -0.1em;
}